﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Core.Common;
using Core.Interfaces;
using Core.DataAccess;
using Core.DataAccess.IRepositories;
using Core.BusinessLogic.Interfaces;

namespace Core.BusinessLogic
{
    [Export(typeof(ILocationService))]
    public class LocationService : ILocationService
    {
        [Import]
        private IAccountRepository _accountRepository;
        [Import]
        private ILocationRepository _locationRepository;

        public LocationService()
        {
            MEFManager.Compose(this);
        }

        public void SaveLocation(Location location)
        {
            _locationRepository.SaveLocation(location);
        }

        public List<Location> GetLocationListByAccountID(Int32 accountID)
        {
            return _locationRepository.GetLocationListByAccountID(accountID);
        }

        public Location GetLocationByLocationID(Int32 locationID)
        {
            return _locationRepository.GetLocationByLocationID(locationID);
        }

        public Location GetLocationByLocationName(string locationName)
        {
            return _locationRepository.GetLocationByLocationName(locationName);
        }

        public void SaveAccountLocation(AccountLocation al)
        {
            _locationRepository.SaveAccountLocation(al);
        }

        public List<AccountLocation> GetAccountLocationByUsername(string username)
        {
            return _locationRepository.GetAccountLocationByUsername(username);
        }

        public List<AccountLocation> GetAccountLocationByAccountID(Int32 accountID)
        {
            return _locationRepository.GetAccountLocationByAccountID(accountID);
        }

        public List<Account> GetAllFriendsLocationByAccountID(int accountID, string locationName)
        {
            return _locationRepository.GetAllFriendsLocationByAccountID(accountID, locationName);
        }

        public int UpdateLocationInfo(int accountID, Location location)
        {
            return _locationRepository.UpdateLocationInfo(accountID, location);
        }

        public int UpdateAccountLocationInfo(int accountID, AccountLocation accLocation, int locationID)
        {
            return _locationRepository.UpdateAccountLocationInfo(accountID, accLocation, locationID);
        }
    }
}
